package com.lxl.bt.util;

import android.graphics.drawable.Drawable;
import android.widget.TextView;

/**
 * Create by lvxinlong
 * on 2020年5月9日10:41:19
 **/
public class TextViewUtils {
    //设置方向
    private static final int LEFT = 1, TOP = 2, RIGHT = 3, BOTTOM = 4;
    public static  void drawDrawable(TextView tv,Drawable mDrawable, int mWidth, int mHeight, int mLocation) {
        if (mDrawable != null) {
            if (mWidth != 0 && mHeight != 0) {
                mDrawable.setBounds(0, 0, mWidth, mHeight);
            }
            switch (mLocation) {
                case LEFT:
                    tv.setCompoundDrawables(mDrawable, null,
                            null, null);
                    break;
                case TOP:
                    tv.setCompoundDrawables(null, mDrawable,
                            null, null);
                    break;
                case RIGHT:
                    tv.setCompoundDrawables(null, null,
                            mDrawable, null);
                    break;
                case BOTTOM:
                    tv.setCompoundDrawables(null, null, null,
                            mDrawable);
                    break;
            }
        }
    }
    public static  void drawDrawable(TextView tv,Drawable mDrawable, int mWidth, int mHeight, int mLocation,int drawpadding) {
        if (mDrawable != null) {
            if (mWidth != 0 && mHeight != 0) {
                mDrawable.setBounds(0, 0, mWidth, mHeight);
            }
            switch (mLocation) {
                case LEFT:
                    tv.setCompoundDrawables(mDrawable, null,
                            null, null);
                    break;
                case TOP:
                    tv.setCompoundDrawables(null, mDrawable,
                            null, null);
                    break;
                case RIGHT:
                    tv.setCompoundDrawables(null, null,
                            mDrawable, null);
                    break;
                case BOTTOM:
                    tv.setCompoundDrawables(null, null, null,
                            mDrawable);
                    break;
            }
            tv.setCompoundDrawablePadding(drawpadding);
        }
    }



}
